package cn.edu.ctbu.labtest.dao;

import cn.edu.ctbu.labtest.domain.Student;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
 * 学生仓库接口
 */
public interface StudentRepository extends JpaRepository<Student,Integer>
{
     Page<Student> findByNameLike(String name, Pageable pageable);

     List<Student> findByNameAndPassword(String name,String password);

    @Query("select o from tb_student o where o.name = :name")
    List<Student> findByName(@Param("name") String name);

//    @Query("select o from tb_student o where o.age=(select max(age) from tb_student )")
//     List<Student> findByMaxAge();

//    @Query("select o from tb_student o where o.name like :name and o.score=:score")
//    List<Student> findByNameScore(@Param("name") String name,@Param("score") Integer score);

//    @Query("select o from tb_student o where o.name like %:name%")
//    List<Student> findByNameLike(@Param("name") String name);
}



